import { message } from 'antd';

const split = ', ';

const beforeUpload = props => info => {
  const { accept, maxSize } = props;
  const size = info.size / 1024 / 1024;
  if (size > maxSize) {
    message.error('文件容量过大！');
    return false;
  }
  if (accept && !accept.split(split).includes(info.type)) {
    message.error('文件类型不支持！');
    return false;
  }
  return true;
};
export default beforeUpload;
